/* 
 * File: main.c
 * Author: Testuya Idota and Brian Fehrman
 * Description: Sends commands to the iRobot
 * 				from the Seeduino via USART
 * 				communication. The robot will
 * 				be commanded to drive in a square,
 * 				turn around, and then drive back.
 * Created on (date): 2-5-2013
 */
#include <avr/io.h>
#include <util/delay.h>
#include <inttypes.h>
#include "usart.h"
#include "iRobotSensors.h"
#include "iRobotControl.h"

int main (void)
{    
	//Initialize USART0 and USART1
	
	//Initialize USART1
	usart_config ucon_1;
	ucon_1.number = 1;
	ucon_1.baudrate = 57600;
	configure_usart(&ucon_1);
	
	//Initialize USART0
	usart_config ucon_0;
	ucon_0.number = 0;
	ucon_0.baudrate = 9600;
	configure_usart(&ucon_0);
	
	//Reconfigure stdout and stdin to call our functions
	stdout = &my_std_out;
	stdin = &my_std_in;
	
	_delay_ms(1000); //wait for a second

	usart1tx((uint8_t)128); //Start
	
	_delay_ms(1000); //wait for a second
	
	usart1tx((uint8_t)132); //to Full Mode
	
	_delay_ms(1000);	

	while(1){
		
		display_sensor_readings( );

		_delay_ms( 500 );
	}

	return -1;
}


